<html>

<head>
    <title>Socket.io</title>
    <script src="socket.io.js"></script>
    <script>
        // 端口号默认80，可不写；
        var socket = io.connect('http://127.0.0.1:10000');
        socket.on('server_event', function(data){
            console.log(data);
        });
        function send() {
            var msg = document.getElementById("msg").value;
            if (msg == '') return;
            socket.emit('client_event', {msg: msg});
            document.getElementById("msg").value = '';
        }
    </script>
</head>

<body>
<input type="text" id="msg"/>
<button onclick="send()">Send</button>
</body>
</html>